package com.hnucm.springboot.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.multipart.MultipartFile;

import java.io.File;
import java.io.IOException;
import java.util.UUID;

@Controller
public class FileController {
    @RequestMapping("file")
    public String file() {
        return "file.html";
    }

    @RequestMapping("filecommint")
    public String filecommint(MultipartFile file)  {
        String filedirs="D:/data/";
        String filename= UUID.randomUUID()+file.getOriginalFilename();
        try {
            file.transferTo(new File(filedirs+filename));
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
        return "success.html";
    }

}
